<html>
<head><meta charset="utf-8"><title>Building via commandline and cargo reference are different · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html">Building via commandline and cargo reference are different</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216591368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216591368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216591368">(Nov 13 2020 at 10:12)</a>:</h4>
<p>Hi all, I'm trying to use the glam-rs project with no_std: <a href="https://github.com/bitshifter/glam-rs">https://github.com/bitshifter/glam-rs</a> and we're hitting a really bizzare issue (been talking with bitshifter, they don't know what's happening either). This PR added <code>no_std</code> support, via referencing <code>num-traits</code> and enabling its <code>libm</code> feature <a href="https://github.com/bitshifter/glam-rs/pull/88">https://github.com/bitshifter/glam-rs/pull/88</a></p>
<p>If you clone the project and run <code>cargo build --no-default-features --features libm</code> in the repo, it builds fine.<br>
If you create a new empty project, and add <code>glam = { git = "https://github.com/bitshifter/glam-rs.git", default-features = false, features = ["libm"] }</code> to its dependencies, it fails to build.<br>
For future reproducibility, the current HEAD of the repo is <a href="https://github.com/rust-lang/rust/commit/454e9c810feadc594aa5519943cbf7d3bcc8ef23">454e9c810feadc594aa5519943cbf7d3bcc8ef23</a>.</p>
<p>The reason I'm asking here instead of in <code>glam-rs</code> channels is to ask why those are inconsistent (not necessarily figure out a fix) - why does one work, and the other doesn't? It feels like a cargo bug to me, but idk.</p>



<a name="216596854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216596854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216596854">(Nov 13 2020 at 11:13)</a>:</h4>
<p>Update: bitshifter has pushed a fix, and so the current HEAD works both ways. However, I'm still curious as to how the two builds are different.</p>



<a name="216602856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216602856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216602856">(Nov 13 2020 at 12:21)</a>:</h4>
<p>If you add <code>-v</code> to show the rustc invocations, what is the difference between the two cases?</p>



<a name="216603961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216603961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216603961">(Nov 13 2020 at 12:35)</a>:</h4>
<p>Ah right, forgot those two existed :P - looks like the only difference other than paths and hashes is that the cmdline to build glam has <code>-C incremental=/home/khyperia/me/glam-rs/target/debug/incremental</code>, and the cargo reference has <code>--cap-lints allow</code></p>



<a name="216605253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216605253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216605253">(Nov 13 2020 at 12:48)</a>:</h4>
<p>oh, looks like <code>num_traits</code> (a dependency of <code>glam</code>) is compiled differently: on the commandline, it is compiled with <code>--cfg 'feature="default"' --cfg 'feature="libm"' --cfg 'feature="std"'</code>, but on the cargo reference, it is compiled with just <code>--cfg 'feature="libm"'</code>. That's... really weird, considering the commandline contained <code>--no-default-features</code>?</p>



<a name="216610009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216610009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216610009">(Nov 13 2020 at 13:31)</a>:</h4>
<p>Yep, that pretty much looks like a <code>dev-dependency</code> infecting a non dev one (in this case, with the <code>default</code> [set of] feature[s] for <code>num-traits</code>)</p>



<a name="216610339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216610339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216610339">(Nov 13 2020 at 13:34)</a>:</h4>
<p>You can try to "debug" the behavior using <code>cargo clean &amp;&amp; CARGO_LOG=trace cargo c --no-default-features --features libm -vv</code> and then <code>grep</code> the hell out of that <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="216610433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216610433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216610433">(Nov 13 2020 at 13:34)</a>:</h4>
<p>FWIW, I've been doing a bit of that atm, and only when I commented out the dev-dependencies (and  thus the benches) out of the <code>Cargo.toml</code>, did the <code>default</code> feature of <code>num-traits</code> disappear</p>



<a name="216611517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216611517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216611517">(Nov 13 2020 at 13:42)</a>:</h4>
<p>(deleted)</p>



<a name="216611683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216611683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Hauck <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216611683">(Nov 13 2020 at 13:43)</a>:</h4>
<p>Aah okay, looks like glam has a dev-dependency on criterion, which <em>does</em> has a dependency on num-traits but default-features = false, however, criterion depends on plotters, which depends on num-traits with default-features = true</p>



<a name="216613360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216613360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216613360">(Nov 13 2020 at 13:55)</a>:</h4>
<p>Demo: <a href="https://asciinema.org/a/8sanMmZL7mFb389yhFz1iTAeX">https://asciinema.org/a/8sanMmZL7mFb389yhFz1iTAeX</a></p>



<a name="216615716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Building%20via%20commandline%20and%20cargo%20reference%20are%20different/near/216615716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Building.20via.20commandline.20and.20cargo.20reference.20are.20different.html#216615716">(Nov 13 2020 at 14:13)</a>:</h4>
<p>FYI, <a href="https://doc.rust-lang.org/cargo/reference/unstable.html#resolver">https://doc.rust-lang.org/cargo/reference/unstable.html#resolver</a><br>
is an unstable set of flags that separate dev/regular deps features.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>